﻿Public Class HotKeyDefs

#Region "Private Members"

    Private mModifier As Int32

#End Region

#Region "Public interface"

    Public Enum HotkeyFlags
        MOD_ALT = &H1
        MOD_CONTROL = &H2
        MOD_SHIFT = &H4
        MOD_WIN = &H8
    End Enum
    Public Const WM_HOTKEY As Integer = &H312


    Public Property AltKey() As Boolean
        Get
            Return CType((mModifier And HotkeyFlags.MOD_ALT), Boolean)
        End Get
        Set(ByVal Value As Boolean)
            If Value Then
                mModifier = mModifier Or HotkeyFlags.MOD_ALT
            Else
                mModifier = mModifier And (Not HotkeyFlags.MOD_ALT)
            End If
        End Set
    End Property

    Public Property CtrlKey() As Boolean
        Get
            Return CType((mModifier And HotkeyFlags.MOD_CONTROL), Boolean)
        End Get
        Set(ByVal Value As Boolean)
            If Value Then
                mModifier = mModifier Or HotkeyFlags.MOD_CONTROL
            Else
                mModifier = mModifier And (Not HotkeyFlags.MOD_CONTROL)
            End If
        End Set
    End Property

    Public Property ShiftKey() As Boolean
        Get
            Return CType((mModifier And HotkeyFlags.MOD_SHIFT), Boolean)
        End Get
        Set(ByVal Value As Boolean)
            If Value Then
                mModifier = mModifier Or HotkeyFlags.MOD_SHIFT
            Else
                mModifier = mModifier And (Not HotkeyFlags.MOD_SHIFT)
            End If
        End Set
    End Property

    Public Property WinKey() As Boolean
        Get
            Return CType((mModifier And HotkeyFlags.MOD_WIN), Boolean)
        End Get
        Set(ByVal Value As Boolean)
            If Value Then
                mModifier = mModifier Or HotkeyFlags.MOD_WIN
            Else
                mModifier = mModifier And (Not HotkeyFlags.MOD_WIN)
            End If
        End Set
    End Property

    Public ReadOnly Property ModifierFlags() As Int32
        Get
            Return mModifier
        End Get
    End Property


#End Region

#Region "Public constructors"
    Public Sub New()

    End Sub

    Public Sub New(ByVal AltKey As Boolean, ByVal ShiftKey As Boolean, ByVal CtrlKey As Boolean, ByVal WinKey As Boolean)

        Me.New()

        Me.AltKey = AltKey
        Me.ShiftKey = ShiftKey
        Me.CtrlKey = CtrlKey
        Me.WinKey = WinKey

    End Sub

    Public Sub New(ByVal Modifier As Int32)
        Me.New()
        mModifier = Modifier
    End Sub
#End Region

#Region "Overloaded interface"
    Public Overloads Function Equals(ByVal Test As HotKeyDefs) As Boolean

        Return (Test.ModifierFlags = ModifierFlags)

    End Function

    Public Overloads Function ToString() As String
        Return ("AltKey=" & AltKey.ToString & ":CtrlKey=" & CtrlKey.ToString & ":ShiftKey=" & ShiftKey.ToString & ":WinKey=" & WinKey.ToString)
    End Function

#End Region

End Class
